home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cdity / ModeProSrc.lha / Daemon / MPWinPatch.c < prev    next >
C/C++ Source or Header  |  1998-11-02  |  5KB  |  199 lines

  1. #define DEBUG
  2. #include "MP.h"
  3. #include <debug.h>
  4. #include "patchdata.h"
  5. #include <tagitemmacros.h>
  6.  
  7. #define ADD_DEBUG_CODE
  8.  
  9. extern struct MPSem *MPSem;
  10. extern struct Window ASM *(*OldOpenWindow)(REG __a0 struct NewWindow *nw,
  11.                                            REG __a6 struct IntuitionBase *lib);
  12. extern struct Window ASM *(*OldOpenWindowTagList)(REG __a0 struct NewWindow *nw,
  13.                                                   REG __a1 struct TagItem *tags,
  14.                                                   REG __a6 struct IntuitionBase *lib);
  15. extern BOOL ASM *(*OldLayoutMenusA)(REG __a0 struct Menu *fm,
  16.                                     REG __a1 APTR vi, 
  17.                                     REG __a2 struct TagItem *tags,
  18.                                     REG __a6 struct Library *lib);
  19.  
  20.  
  21. struct Window __saveds ASM *NewOpenWindow(REG __a0 struct ExtNewWindow *nw,
  22.                                           REG __a6 struct IntuitionBase *IBase)
  23. {
  24.   STRPTR pubname;
  25.   struct Screen *scr=0;
  26.   struct Window *w;
  27.   ULONG oldflags;
  28.  
  29.   char tnamebuffer[52];
  30.   char *tname;
  31.   ULONG stack1=0xc0de0010;
  32.  
  33.   DoNothing(&stack1);
  34.  
  35.   tname=SetupTaskName(tnamebuffer,", OW",50);  
  36.   
  37. DEBUG_CODE( 
  38.             DKP("OpenWindow(%8lx)\n",nw);
  39.             PrintNewWindowData(nw);
  40.           );
  41.  
  42.   oldflags=nw->Flags;                 // Store orignal flags
  43.  
  44.   if(nw->Flags & WFLG_NW_EXTENDED)    // order changed 
  45.   {
  46.     /* validate ram *///                                                                               (4.60.1)
  47.     if(((ULONG)nw->Extension & 1)==0 && TypeOfMem(nw->Extension))//                                    (4.60.1)
  48.     {
  49.       if(pubname=(STRPTR)GetTagData(WA_PubScreenName,0,nw->Extension))
  50.       {
  51.         /* Make sure this screen exeist */
  52.         scr=LockPubScreen(pubname);
  53.       }
  54.     }
  55.   }
  56.  
  57.   if(MPSem->EnabledNLM)  // order changed
  58.   {
  59.     nw->Flags|=WFLG_NEWLOOKMENUS;
  60.   }
  61.  
  62.  
  63.   w=OldOpenWindow((struct NewWindow *)nw,IBase);
  64.   
  65.   if(scr)
  66.   {
  67.     UnlockPubScreen(0,scr);
  68.   }
  69.   
  70.   nw->Flags=oldflags;                 // restore orignal flags
  71.   
  72. #ifdef ADD_DEBUG_CODE
  73.   if(MPSem->Debug)
  74.   {
  75.     DKP("  RV=%8lx\n",w);
  76.   }
  77. #endif
  78.  
  79.   SetTaskName(tname);
  80.  
  81.   return(w);
  82. }
  83.  
  84. struct Window __saveds ASM *NewOpenWindowTagList(REG __a0 struct ExtNewWindow *nw,
  85.                                                  REG __a1 struct TagItem *TagList,
  86.                                                  REG __a6 struct IntuitionBase *IBase)
  87. {
  88.   STRPTR pubname;
  89.   struct Screen *scr=0;
  90.   struct Window *w;
  91.   struct TagItem ti[]={WA_NewLookMenus , TRUE , 
  92.                        TAG_DONE , 0};
  93.  
  94.   char tnamebuffer[52];
  95.   char *tname;
  96.   ULONG stack1=0xc0de0011;
  97.  
  98.   DoNothing(&stack1);
  99.   
  100.   tname=SetupTaskName(tnamebuffer,", OWTL",50);  
  101.  
  102. DEBUG_CODE(//                                                                                          (4.56.2)
  103.    DKP("OpenWindowTagList(%8lx,%8lx)\n",nw,TagList);//                                                 (4.56.2)
  104.    PrintNewWindowData(nw);//
  105.    PrintWindowTags(TagList);//                                                                         (4.56.2)
  106.       );  //                                                                                           (4.56.2)
  107.  
  108.   if(MPSem->EnabledNLM)  
  109.   {
  110.     if(TagList)
  111.     {
  112.       ti[1].ti_Tag =TAG_MORE;
  113.       ti[1].ti_Data=(ULONG)TagList;
  114.     }
  115.     TagList=ti;              
  116.   }
  117.  
  118.   if(pubname=(STRPTR)GetTagData(WA_PubScreenName,0,TagList))
  119.   {
  120.     /* Make sure this screen exeist */
  121.     scr=LockPubScreen(pubname);
  122.   }
  123.  
  124.   w=(struct Window *)OldOpenWindowTagList((struct NewWindow *)nw,TagList,IBase);
  125.  
  126.   if(scr)
  127.   {
  128.     UnlockPubScreen(0,scr);
  129.   }
  130.  
  131. #ifdef ADD_DEBUG_CODE
  132.   if(MPSem->Debug)
  133.   {
  134.     DKP("  RV=%8lx\n",w);
  135.   }
  136. #endif
  137.   
  138.   SetTaskName(tname);
  139.   
  140.   return(w); 
  141. }
  142.  
  143. BOOL __saveds ASM NewLayoutMenusA(REG __a0 struct Menu *fm,
  144.                                   REG __a1 APTR vi, 
  145.                                   REG __a2 struct TagItem *tags,
  146.                                   REG __a6 struct Library *GTBase)
  147. {
  148.   BOOL rv;
  149.   struct TagItem ti[]=
  150.   {
  151.     GTMN_NewLookMenus,TRUE,
  152.     TAG_DONE,0
  153.   };
  154.  
  155.   char tnamebuffer[52];
  156.   char *tname;
  157.   ULONG stack1=0xc0de0012;
  158.   
  159.   DoNothing(&stack1);
  160.   
  161.   tname=SetupTaskName(tnamebuffer,", LMA",50);  
  162.  
  163.  
  164. #ifdef ADD_DEBUG_CODE
  165.   if(MPSem->Debug)
  166.   {
  167.     DKP("LayoutMenus(%8lx,%8lx,%8lx) -- %s\n",fm,vi,tags,FindTask(0)->tc_Node.ln_Name);
  168.   }
  169. #endif
  170.  
  171. //  ObtainSemaphoreShared(&MPSem->ListSem);
  172.  
  173.   if(MPSem->EnabledNLM)    
  174.   {
  175.     if(tags)
  176.     {
  177.       ti[1].ti_Tag=TAG_MORE;
  178.       ti[1].ti_Data=(ULONG)tags;
  179.     }
  180.     tags=ti;
  181.   }
  182.  
  183.   rv=(BOOL)OldLayoutMenusA(fm,vi,tags,GTBase);
  184.   
  185. #ifdef ADD_DEBUG_CODE
  186.   if(MPSem->Debug)
  187.   {
  188.     DKP("  RV=%8lx\n",rv);
  189.   }
  190. #endif
  191.   
  192. //  ReleaseSemaphore(&MPSem->ListSem);
  193.   
  194.   SetTaskName(tname);
  195.   
  196.   return(rv); 
  197. }
  198.  
  199.